part of '../text.dart';

class TextFormat {
  String font;
  num size;
  int color;
  num strokeWidth;
  int strokeColor;
  GraphicsGradient? fillGradient;

  int weight;
  bool bold;
  bool italic;
  bool underline;
  String align;
  String verticalAlign;

  num topMargin;
  num bottomMargin;
  num leftMargin;
  num rightMargin;
  num indent;
  num leading;

  //-------------------------------------------------------------------------------------------------

  TextFormat(this.font, this.size, this.color,
      {this.strokeWidth = 0.0,
      this.strokeColor = Color.Black,
      this.fillGradient,
      this.weight = 400,
      this.bold = false,
      this.italic = false,
      this.underline = false,
      this.align = 'left',
      this.verticalAlign = 'top',
      this.topMargin = 0.0,
      this.bottomMargin = 0.0,
      this.leftMargin = 0.0,
      this.rightMargin = 0.0,
      this.indent = 0.0,
      this.leading = 0.0});

  //-------------------------------------------------------------------------------------------------

  TextFormat clone() => TextFormat(font, size, color,
      strokeWidth: strokeWidth,
      strokeColor: strokeColor,
      fillGradient: fillGradient,
      weight: weight,
      bold: bold,
      italic: italic,
      underline: underline,
      align: align,
      verticalAlign: verticalAlign,
      topMargin: topMargin,
      bottomMargin: bottomMargin,
      leftMargin: leftMargin,
      rightMargin: rightMargin,
      indent: indent,
      leading: leading);

  //-------------------------------------------------------------------------------------------------

  String get _cssFontStyle {
    var fontStyle = '$weight ${size}px $font';
    if (bold) fontStyle = 'bold ${size}px $font';
    if (italic) fontStyle = 'italic $fontStyle';
    return fontStyle;
  }
}
